﻿using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using WMSABL;
using WMSABL.SY;
using WMSAML.SY;
using ElectronicWMSA.Comm.ClassFiles;
using ElectronicWMSA.Comm.Forms.Message;

namespace ElectronicWMSA.Warehouse
{
    public partial class Frm_Weight : Form
    {
        private string strWhere = "";
        public Frm_Weight()
        {
            InitializeComponent();
            dtpTimeStart.Checked = false;
            dtpTimeEnd.Checked = false;
            this.page1.PageCurrent = 1;
            this.page1.PageSize = 50;
            this.page1.Bind();
        }
        private int DBindData()
        {
            ElectronicWMSA.Comm.Forms.MsControls.PageData pageData = new ElectronicWMSA.Comm.Forms.MsControls.PageData();
            pageData.TableName = "T_ProWeight";
            pageData.PrimaryKey = "ProductWeight_Id";
            pageData.OrderStr = "ProductWeight_Id  desc";
            pageData.PageIndex = this.page1.PageCurrent;
            pageData.PageSize = this.page1.PageSize;
            pageData.QueryCondition = strWhere;
            pageData.QueryFieldName = "*";

            this.page1.bindingSource.DataSource = pageData.QueryDataTable().Tables[0];
            this.page1.bindingNavigator.BindingSource = page1.bindingSource;
            this.dataGridViewUserList.AutoGenerateColumns = false;
            this.dataGridViewUserList.DataSource = this.page1.bindingSource;
            this.dataGridViewUserList.ClearSelection();
            this.dataGridViewUserList.CurrentCell = null;
            return pageData.TotalCount;
        }
        private int pageControlU_EventPaging(ElectronicWMSA.Comm.Forms.MsControls.EventPagingArg e)
        {
            return DBindData();
        }
        private void dataGridViewUserList_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            SolidBrush b = new SolidBrush(dataGridViewUserList.RowHeadersDefaultCellStyle.ForeColor);
            e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), dataGridViewUserList.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
        }
        private void btnUserSearch_Click(object sender, EventArgs e)
        {
           // if (!SystemVariable.VaildationPermission("查询")) return;

            this.strWhere = " 1=1 ";
            if (dtpTimeStart.Checked)
            {
                strWhere += " and  convert(varchar(10),Update_time,120) >='" + dtpTimeStart.Text.Trim() + "'";
            }
            if (dtpTimeEnd.Checked)
            {
                strWhere += " and   convert(varchar(10),Update_time,120) <='" + dtpTimeEnd.Text.Trim() + "'";
            }
            if (!string.IsNullOrEmpty(txt_KW.Text.Trim()))
            {
                strWhere += "  and packinglistmain_no like '%" + txt_KW.Text.Trim() + "%'";
            }
            if (!string.IsNullOrEmpty(txt_Machine.Text.Trim()))
            {
                strWhere += "  and PC_Order_No like '%" + txt_Machine.Text.Trim() + "%'";
            }
            //string statTime = dtpTimeStart.Value.ToString("yyyy/MM/dd " + " 00:00:00");
            //string EndTime = dtpTimeEnd.Value.ToString("yyyy/MM/dd HH:mm:ss");

            //this.strWhere += " CreatTime BETWEEN '" + statTime + "'  AND '" + EndTime + "'";
            //if (this.txtPickingNuber.Text.Trim() != "")
            //    this.strWhere += " AND PickNO='" + this.txtPickingNuber.Text.Trim() + "' ";
            //if (this.comBox_Stauts.Text != "" && this.comBox_Stauts.Text != "--请选择--")
            //    this.strWhere += " AND Stauts='" + this.comBox_Stauts.Text.Trim() + "' ";
            //if (this.txt_Username.Text.Trim() != "")
            //    this.strWhere += " AND UserName='" + this.txt_Username.Text.Trim() + "' ";

            this.page1.Bind();
        }
        private void linkLabelClose_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Main._Main.CloseTabPages();
        }
        private void linkLabellinkLabelCloseAll_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Main._Main.CloseAllTabPages();
        }
        private void linkLabelCloseElse_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Main._Main.CloseTabPageElse();
        }
    }
}
